SHELL	:= /bin/sh
SRCDIR	:= ./
DEPDIR	:= $(SRCDIR)
OBJDIR	:= $(SRCDIR)objs/
C_SRC	:= $(wildcard $(SRCDIR)*.c)
OBJS	:= $(patsubst $(SRCDIR)%.c,%.o,$(C_SRC))
DEPS	:= $(wildcard $(DEPDIR)*.h)
CC	:= i486-mingw32-gcc
CFLAGS	:= -Wall -O
LDFLAGS	:= -lm -mwindows
VPATH	:= $(OBJDIR)
BINARY	:= schweissroboter.exe

.SUFFIXES:

.PHONY: all
all: schweissroboter

schweissroboter: $(OBJS)
	$(CC) $(LDFLAGS) -o $(BINARY) $(addprefix $(OBJDIR),$(OBJS))

$(OBJS): %.o: $(SRCDIR)%.c
	@mkdir $(OBJDIR) -p
	$(CC) $(CFLAGS) -c $< -o $(OBJDIR)$@

depends.mk: $(C_SRC) $(DEPS)
	$(CC) -MM $(C_SRC) > depends.mk

ifneq ($(MAKECMDGOALS),clean)
include depends.mk
endif

.PHONY: clean
clean:
	-@rm -rf $(OBJDIR) depends.mk $(BINARY) *~
